home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / int_23.arc / INT23.ASM next >
Assembly Source File  |  1988-03-15  |  1KB  |  60 lines

  1. ;    Static Name Aliases
  2. ;
  3.     TITLE   int23
  4. ;    NAME    int23.asm
  5.  
  6. ;    This code, written in a rather paranoid fashion, allows one to post an
  7. ;    int 23.  If you try to do it with the standard int86() library call, you
  8. ;    will generate an error, as the stack isn't properly restored.
  9. ;
  10. ;    This code comes from a complete ARC file with a demonstration program and
  11. ;    documentation.  If you do not have the whole ARC, it is available from the
  12. ;    MSOFT forum on CompuServe.
  13.  
  14. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  15. _TEXT    ENDS
  16. _DATA    SEGMENT  WORD PUBLIC 'DATA'
  17. _DATA    ENDS
  18. CONST    SEGMENT  WORD PUBLIC 'CONST'
  19. CONST    ENDS
  20. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  21. save_ss    dw    ?
  22. save_sp    dw    ?
  23. _BSS    ENDS
  24. DGROUP    GROUP    CONST,    _BSS,    _DATA
  25.     ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  26.  
  27. _TEXT      SEGMENT
  28.  
  29.     PUBLIC    _int23
  30. _int23    PROC NEAR
  31.  
  32.     push bp            ; save bp
  33.     mov    bp,sp        ; setup stack frame to allow CV walkback
  34.  
  35.     push di
  36.     push si
  37.     push ds
  38.     push es
  39.     mov    save_sp,sp    ; sp needs to be stored in a safe place
  40.     mov    save_ss,ss    ; ss also needs to be stored somewhere safe
  41.  
  42.     int    23h            ; post a ^C interrupt
  43.  
  44.     cli                ; old chips had a bug that requires this
  45.     mov    ss,save_ss    ; ss can now be restored from it's hiding place
  46.     mov    sp,save_sp    ; sp needs to be restored, too
  47.     sti                ; other end of hardware bug fix
  48.  
  49.     pop es
  50.     pop ds
  51.     pop si
  52.     pop di
  53.  
  54.     pop bp            ; do NOT issue a mov sp,bp - bp is unreliable
  55.     ret    
  56.  
  57. _int23    ENDP
  58. _TEXT    ENDS
  59. END
  60.